import { defineStore } from 'pinia'
import http from '../utils/http'

export const useStatusStore = defineStore('status', {
    state: () => ({
        serialOpened: false, // 串口是否打开
    }),
    actions: {
        async openSerial() {
            const res = await http.get('/open-serial')
            if (res.success) {
                this.serialOpened = true

                return true
            }

            return false
        },
        closeSerial() {
            this.serialOpened = false
        },
    },
})
